package com.martin.fastframe.ui.main

import android.content.Context
import com.martin.fastframe.ui.binding.adapter.BindingAdapterActivity
import com.martin.fastframe.ui.blood.strip.BloodStripActivity
import com.martin.fastframe.ui.ceiling.CeilingActivity
import com.martin.fastframe.ui.danmu.DanMuActivity
import com.martin.fastframe.ui.dialog.CommentInputDialogModel
import com.martin.fastframe.ui.flow.FlowActivity
import com.martin.fastframe.ui.like.follow.LikeFollowActivity
import com.martin.fastframe.ui.page.index.PageIndexActivity
import com.martin.fastframe.ui.penetrate.PenetrateActivity
import com.martin.fastframe.ui.radius.RadiusActivity
import com.martin.fastframe.ui.shpe.ShapeActivity
import com.martin.lib_base.base.BaseViewModel
import com.martin.lib_base.bean.PreviewBean
import com.martin.lib_base.ktx.showToast
import com.martin.lib_base.ui.PreviewActivity
import com.martin.lib_base.utils.MediaUtil

class MainViewModel : BaseViewModel() {

    val viewHolders = listOf(TextViewHolder::class.java)

    //评论输入弹窗
    private val _commentInputDialog by lazy {
        CommentInputDialogModel()
    }

    //列表数据
    val items = listOf(
        "评论输入弹窗",
        "弹幕",
        "Radius",
        "BindingAdapter",
        "Shape",
        "Fragment 点击穿透",
        "PageIndex",
        "PK血条",
        "点赞跟随",
        "flow",
        "Preview",
        "选择图片",
        "自定义",
        "吸顶",
    )

    /**
     * 条目点击事件
     */
    fun onItemClick(context: Context, position: Int) {
        when (items[position]) {
            "评论输入弹窗" -> _commentInputDialog.show()
            "弹幕" -> DanMuActivity.start(context)
            "Radius" -> RadiusActivity.start(context)
            "BindingAdapter" -> BindingAdapterActivity.start(context)
            "Shape" -> ShapeActivity.start(context)
            "Fragment 点击穿透" -> PenetrateActivity.start(context)
            "PageIndex" -> PageIndexActivity.start(context)
            "PK血条" -> BloodStripActivity.start(context)
            "点赞跟随" -> LikeFollowActivity.start(context)
            "flow" -> FlowActivity.start(context)
            "Preview" -> PreviewActivity.start(context, listOf(
                "https://th.bing.com/th/id/R.82ece114307f62dc0b8aa2c366b9ef37?rik=GwmaljjvGJ75zg&riu=http%3a%2f%2fimg.pconline.com.cn%2fimages%2fupload%2fupc%2ftx%2fwallpaper%2f1308%2f15%2fc2%2f24494094_1376530595238.jpg&ehk=L%2fNVdWJDsmRvIsmKuuUcvCGnK4DJwpxad4JswscWIN0%3d&risl=&pid=ImgRaw&r=0",
                "https://th.bing.com/th/id/R.82ece114307f62dc0b8aa2c366b9ef37?rik=GwmaljjvGJ75zg&riu=http%3a%2f%2fimg.pconline.com.cn%2fimages%2fupload%2fupc%2ftx%2fwallpaper%2f1308%2f15%2fc2%2f24494094_1376530595238.jpg&ehk=L%2fNVdWJDsmRvIsmKuuUcvCGnK4DJwpxad4JswscWIN0%3d&risl=&pid=ImgRaw&r=0",
                "https://th.bing.com/th/id/R.82ece114307f62dc0b8aa2c366b9ef37?rik=GwmaljjvGJ75zg&riu=http%3a%2f%2fimg.pconline.com.cn%2fimages%2fupload%2fupc%2ftx%2fwallpaper%2f1308%2f15%2fc2%2f24494094_1376530595238.jpg&ehk=L%2fNVdWJDsmRvIsmKuuUcvCGnK4DJwpxad4JswscWIN0%3d&risl=&pid=ImgRaw&r=0",
            ).map { PreviewBean(it) })

            "自定义" -> {
            }

            "选择图片" -> {
                MediaUtil.pickImage(context, 1) {

                }
            }

            "吸顶" -> CeilingActivity.start(context)

            else -> showToast(items[position])
        }
    }
}